class Task32_2:
    def run(self, tree):
        queue1 = []
        queue2 = []
        result = []
        if tree is not None:
            queue1.append(tree)
        while len(queue1) + len(queue2) > 0:
            layer = []
            for node in queue1:
                layer.append(node.val)
                if node.left is not None:
                    queue2.append(node.left)
                if node.right is not None:
                    queue2.append(node.right)
            result.append(layer)
            queue1 = queue2
            queue2 = []
        return result
